package com.holly.unit.deform.designer.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 类描述: 高级字段元素枚举
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/8/4 11:22
 */
public enum  AdvanceElementEnum {


    /** 自定义区域*/
    BLANK("blank"),

    /** 自定义组件*/
    COMPONENT("component"),

    /** 文件*/
    FILEUPLOAD("fileupload"),

    /** 图片*/
    IMGUPLOAD("imgupload"),

    /** 编辑器*/
    EDITOR("editor"),

    /** 子表单*/
    TABLE("table"),

    // 子表单+
    SUBFORM("subform");

    String fieldName;

    AdvanceElementEnum(String fieldName) {
        this.fieldName = fieldName;
    }

    public String fieldName() {
        return this.fieldName;
    }

    public static AdvanceElementEnum of(String fieldName) {
        return Stream.of(AdvanceElementEnum.values())
                .filter(clazz -> Objects.equals(clazz.fieldName(), fieldName))
                .findFirst()
                .orElse(BLANK);
    }

}
